import dayjs from "dayjs";

export const timeFormatStr = 'HH:mm:ss';
export const dateFormatStr = 'YYYY-MM-DD';
export const allFormatStr = dateFormatStr + ' ' + timeFormatStr;
export const serveDateFormat = '';
export const monthFormatStr = 'YYYY-MM';

export const formatServerDate = (dateStr, format) => {
    return formatDate(dayjs(dateStr), format || allFormatStr);
};

export const toDate = (dateStr, format) => {
    if(!dateStr){
        return dayjs();
    }

    return dayjs(dateStr, format || allFormatStr);
};

export const formatDate = (dayData, format) => {
    return dayData.format(format || allFormatStr);
};